import { Controller, Get, Query} from '@nestjs/common';
import {UserService} from './service/user.service';
import {BaseController} from "@/modules/_/base/base.controller";
import {User} from '@/entitys/base/user.entity';
import {classTransformerUtils} from "@/utils/classTransformerUtils";

@Controller("/user")
export class UserController extends BaseController<User> {
    Service: UserService;

    constructor(Service: UserService) {
        super(Service);
        this.Service = Service;
    }

    @Get("/login")
    login(@Query("userName") userName: string, @Query("password") password: string) {
        return this.Service.login(classTransformerUtils.plainToClass(User, {phone: userName, password}));
    }

    @Get("/getUserInfo")
    getUserInfo() {
        return this.Service.getMyUserInfo();
    }
}
